<template>
	<view class="work-certificate">
		<view class="reject-box" v-if="form.status===3">
			<view class="flex-align-center">
				<static-image src="/pagesA/static/img/order/icon-notice.png" width="40" height="40" margin-right="16"></static-image>
				<view class="font-s-16 fw-b">拒绝原因</view>
			</view>
			<view class="color-666 line-height-44 mar-t-15">{{form.approveRemark || '暂无拒绝原因'}}</view>
		</view>
		<view class="form-card-box">
			<view class="form-box">
				<view class="flex-align-center">
					<view class="fw-b">毕业学校</view>
					<view class="mar-l-24 flex-1">
						<u-input :disabled="[1,2].includes(form.status)" v-model="form.graduateSchool" placeholder="请填写您的就读学校名称"></u-input>
					</view>
				</view>
				<view class="flex-align-center">
					<view class="fw-b">毕业时间</view>
					<view class="mar-l-24 flex-1">
						<text class="" v-if="[1,2].includes(form.status)">{{form.graduationDate}}</text>
						<fu-picker v-else mode="date" v-model="form.graduationDate" placeholder="请选择毕业日期"></fu-picker>
					</view>
				</view>
				<view class="flex-align-center">
					<view class="fw-b">就读专业</view>
					<view class="mar-l-24 flex-1">
						<u-input :disabled="[1,2].includes(form.status)" v-model="form.major" placeholder="请填写您的就读专业"></u-input>
					</view>
				</view>
			</view>
		</view>
		<view class="form-card-box" style="padding: 32rpx 4rpx 12rpx 24rpx;">
			<view class="font-s-14 fw-b">证明材料</view>
			<view class="img-box" v-if="form.graduationCertificatePhoto && [1,2].includes(form.status)">
				<view v-for="(item,index) in JSON.parse(form.graduationCertificatePhoto)" :key="index" class="pic-item">
					<u-image v-if="item" :src="item.url" width="200" height="200" border-radius="8" @click="$common.previewImage(form.graduationCertificatePhoto,index)"></u-image>
				</view>
			</view>
			<view class="mar-t-15 flex-between-center" v-else>
				<image-upload v-model="form.graduationCertificatePhoto" max-count="6" uploadText="毕业证书照"></image-upload>
			</view>
		</view>
		<footer-btn v-if="form.status!==2">
			<u-button v-if="form.status===1" hover-class="none" shape="circle" type="primary" :custom-style="{background:'#F5F7FA',color:'#999999',fontSize:'32rpx',fontWeight:'bold',height:'90rpx',letterSpacing: '8rpx'}">正在审核中</u-button>
			<u-button v-else :disabled="btnDisabled" shape="circle" @click="confirm()" type="primary" :custom-style="{background:'#1F78FF',fontSize:'32rpx',fontWeight:'bold',height:'90rpx',letterSpacing: '8rpx'}">确认提交</u-button>
		</footer-btn>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {}
			}
		},
		computed:{
			btnDisabled(){
				return !this.form.graduateSchool || !this.form.graduationDate || !this.form.major || !this.form.graduationCertificatePhoto
			}
		},
		onLoad() {
			this.getDetail()
		},
		methods: {
			getDetail() {
				this.$request({
					url: '/orderInfoIncrIncome/incrEducationProveDetail',
					method: 'get',
				}).then(res => {
					this.form = res.data || {}
				})
			},
			confirm(){
				uni.showLoading({ mask:true })
				this.$request({
					url: '/orderInfoIncrIncome/saveIncrEducationProve',
					method: 'post',
					data: this.form
				}).then(res => {
					this.$u.toast('提交成功');
					this.$common.handleSuccess()
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.work-certificate {
		background-image: url('../static/img/quota/education-header-bg.png');
		background-size: 100% 480rpx;
		background-repeat: no-repeat;
		padding: 232rpx 24rpx 0;
		.img-box{
			display: flex;
			flex-wrap: wrap;
			margin-top: 30rpx;
			>view{
				margin: 0 24rpx 24rpx 0;
				&:nth-child(3n){
					margin-right: 0;
				}
			}
		}
		.form-card-box{
			background: #FFFFFF;
			border-radius: 24rpx;
			padding: 0 24rpx;
			margin-bottom: 24rpx;
		}
		.form-box{
			.mar-l-24{
				margin-left: 48rpx;
			}
			>view{
				height: 108rpx;
				&:not(:last-child){
					border-bottom: 2rpx solid #f5f5f5;
				}
			}
		}
	}
</style>
